﻿using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Text;
using Galoap.JSON;
using Galoap;
using Galoap.Properties;
using Galoap.UnitTest.Storage;
using Galoap.Questions;
using Galoap.UnitTest;
using Galoap.Workflow;
using Galoap.Workflow.Model;
using Galoap.Workflow.ParseScxml;
using System.Collections.Generic;

public partial class game1 : System.Web.UI.Page
{
    static bool postback = false;
    Question wer = null;

    protected void Page_Load(object sender, EventArgs e) {
       /* Workflow w = (Workflow)Session["Workflow"];
        w = null;*/
        /*
        if (!postback)  {
            postback = true;
            try
            {
                User u = Galoap.User.GetUserByNickname("Geniusmax");

                GameSession gs = GameSession.GetLastGameSessionByUser(u);
                gs.GameReference.Load();

                //Game ge = Game.GetGame(5);
                //GameSession gsession = u.GetLastGameSession();
                //GameSession s = Galoap.GameSession.GetLastGameSessionByUser(u);

                Game g = gs.Game;
                // Game g = Game.GetAllGames().OfType<ImageTagGame>().First(); // gs.Game;
                // GameSession gs = GameSession.GetLastGameSessionByGame(g);
                Question itq = g.GetQuestion().First();
                
                itq.Render();
                
            }
            catch (System.ArgumentException) {
                //non c'e l'utente
            }

        }

        Hashtable lista = new Hashtable();
        string risposta = "";
        int value = 100;
        string richiesta = Request.Params[0].ToString();
        try { lista = (Hashtable)JSON.JsonDecode(richiesta); }
        catch (SystemException) { return; }
        try
        {
            string type = (string)lista["event"];
            switch (type)
            {
                case "next":
                    {

                        risposta = "{\"txt\":\"Crea le giuste associazioni.\",\"interrogation\": \"qualcosa\",\"description\":\"Trascina la parola nel suo box.\",\"filejs\": \"URI.js\",\"filecss\": \"URI.css\",\"idocument\":\"Ho|||veduto|||una|||ragazza|||con|||gli|||occhiali.\",\"questionid\": 35,\"knowledge\":\"V|||V|||R|||S|||E|||R|||S\",\"info\":\"\",\"sessionid\": 536}";
                    }
                    break;
                case "gameResult":
                    {
                        risposta = "{\"point\":\"" + value + "\"}";
                    }
                    break;
            }
        }
        catch (NullReferenceException)
        {
            return;
        }
        Response.Write(risposta);
        Response.End();*/
    }
}
